package com.example.bruger.androidneurosky;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

/**
 * Created by Ailain on 19-03-2015.
 */
public class BrightPictureGameActivity extends ActionBarActivity implements TGCallBack{
    ImageView catView;

    int noOfCatsMadeDisappear = 0;
    TextView counter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_brightnessgame);
        TGHandler.SetNewCallBack(this);

        catView = (ImageView) findViewById(R.id.imageView);
        counter = (TextView) findViewById(R.id.counter);
        counter.setText("Number of cats made disappear: 0");

    }

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_brainwave, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }


    @Override
    public void Update(int attention, int meditation, int delta, int theta,
                       int lowAlpha, int highAlpha, int lowBeta, int highBeta,
                       int lowGamma, int midGamma) {
        // Meditation
        ((TextView) findViewById(R.id.meditation_text)).setText("Meditation: " + meditation + " - " + meditation + " %");
        ((ProgressBar) findViewById(R.id.meditation_bar)).setProgress(meditation);
        double alpha = (255-(meditation * 2.55));
        int alphaFinal = (int) alpha;

        catView.setAlpha(alphaFinal);


        if (alphaFinal <= 25)
        {
            noOfCatsMadeDisappear = noOfCatsMadeDisappear + 1;
            counter.setText("Number of cats made disappear: " + noOfCatsMadeDisappear);
            catView.setAlpha(0);
        }
    }
}
